<?php

/* * **************************************************************************************\
 * *   @name		EXP Templates 1.0                                               **
 * *   @package          Joomla 1.6/1.7/2.5                                              **
 * *   @author		EXP TEAM::Alexey Kurguz (Grusha)                                **
 * *   @copyright	Copyright (C) 2005 - 2011  EXP TEAM::Alexey Kurguz (Grusha)     **
 * *   @link             http://www.feellove.eu                                          **
 * *   @license		Commercial License                                              **
  \*************************************************************************************** */
// No direct access.
defined('_JEXEC') or die;

function exptemplate_spancount($var, $num, $mod_name1 = 0, $mod_name2 = 0, $mod_name3 = 0, $mod_name4 = 0, $mod_name5 = 0, $mod_name6 = 0) {
    $returnspan = $num;

    $mod1 = 0;
    $mod2 = 0;
    $mod3 = 0;
    $mod4 = 0;
    $mod5 = 0;
    $mod6 = 0;
    
    if ($var->countModules($mod_name1)) {
        $mod1 = 1;
    }
    if ($var->countModules($mod_name2)) {
        $mod2 = 1;
    }
    if ($var->countModules($mod_name3)) {
        $mod3 = 1;
    }
    if ($var->countModules($mod_name4)) {
        $mod4 = 1;
    }
    if ($var->countModules($mod_name5)) {
        $mod5 = 1;
    }
    if ($var->countModules($mod_name6)) {
        $mod6 = 1;
    }
    $count_mod = $mod1 + $mod2 + $mod3 + $mod4 + $mod5 + $mod6;
    if ($count_mod > 0) {
        $returnspan = $num / $count_mod;
    }
    return $returnspan;
}

function exptemplate_middle_spancount($var, $num, $mod_name1 = 0, $mod_name2 = 0, $mod_name3 = 0) {
    
/*
if ($this->countModules('content-a')) {
    $expcontent_1 = 1;
}
if ($this->countModules('content-b')) {
    $expcontent_2 = 1;
}
if ($this->countModules('content-c')) {
    $expcontent_3 = 1;
}

if($expcontent_1 || $expcontent_2 || $expcontent_3){
    $val_n = $expcontent_1 + $expcontent_2 + $expcontent_3;
    $cont_val = $expcontent%$val_n;
}
if($cont_val){
    $expcontent = $expcontent - $cont_val;
}else{
    $expcontent = $expcontent;
}



if ($this->countModules('feature-a')) {
    $expfeature_1 = 1;
}
if ($this->countModules('feature-b')) {
    $expfeature_2 = 1;
}
if ($this->countModules('feature-c')) {
    $expfeature_3 = 1;
}

if($expfeature_1 || $expfeature_2 || $expfeature_3){
    $val_n_f = $expfeature_1 + $expfeature_2 + $expfeature_3;
    $cont_val_f = $expcontent%$val_n_f;
}
if($cont_val_f){
    $expcontent_f = $expcontent - $cont_val_f;
}else{
    $expcontent_f = $expcontent;
}
*/
//print_r($cont_val);

    $expcontent_1 = 0;
    $expcontent_2 = 0;
    $expcontent_3 = 0;
    $cont_val = 0;
    
    if ($var->countModules($mod_name1)) {
        $expcontent_1 = 1;
    }
    if ($var->countModules($mod_name2)) {
        $expcontent_2 = 1;
    }
    if ($var->countModules($mod_name3)) {
        $expcontent_3 = 1;
    }

    if ($expcontent_1 || $expcontent_2 || $expcontent_3) {
        $val_n = $expcontent_1 + $expcontent_2 + $expcontent_3;
        $cont_val = $num % $val_n;
    }
    if ($cont_val) {
        $expcontent = $num - $cont_val;
    } else {
        $expcontent = $num;
    }
    return $expcontent;
}

?>
